<template>
  <div>
    <div class="slogan">
      <p>你是懂作弊的</p>
    </div>
    <el-container class="app-item-contain">
      <el-header class="align-center">
        <h1 style="font-size: 30px;">{{ form.name }}</h1>
        <br>
        试卷总分: <span style="color: red;" class="sec-title">{{ form.paper_score }}</span>
        <span class="sec-title">所属学科: {{ form.subject_name }}</span>
        <span class="sec-title">创编时间: {{ form.time }}</span>
        <el-divider></el-divider>
      </el-header>
      <br>
      <br>
      <el-main>
        <el-form :model="form" ref="form" v-loading="formLoading" label-width="100px">
          <el-row :key="index" v-for="(topic,index) in form.topicItem">
            <h3>{{ topic.content }}</h3>
            <el-card class="exampaper-item-box" v-if="topic.titles.length!==0">
              <el-form-item :key="title.id" :label="index + 1 + '.'"
                            v-for="(title, index) in topic.titles"
                            class="exam-question-item" label-width="50px" :id="'question-'+ index">
                <ShowTitleAnswer :qType="title.title_type" :question="title"/>
              </el-form-item>
            </el-card>
          </el-row>
        </el-form>
      </el-main>
    </el-container>
    <div class="back-btn">
      <el-button icon="el-icon-d-arrow-left" type="success" style="font-size: 16px;" @click="goBack">返回</el-button>
    </div>
  </div>
</template>

<script>
import ShowTitleAnswer from "../components/ShowTitleAnswer";

export default {
  name: 'ReadPaper',
  components: {ShowTitleAnswer},
  data() {
    return {
      form: {},
      formLoading: false,
      answer: {
        id: null,
        score: 0,
        doTime: 0,
        answerItems: [],
        doRight: false
      }
    }
  },
  created() {
    let id = this.$route.query.id
    if (id && parseInt(id) !== 0) {
      this.formLoading = true
      this.$http({
        url: this.$settings.BASE_URL + `/paper/paper_List/${id}/`,
        method: 'get',
      }).then(res => {
        this.form = res.data.result
        this.formLoading = false
      })
    }
  },
  methods: {
    goBack() {
      this.$router.push('/teacher/PaperList')
    }
  },
  computed: {}
}
</script>

<style lang="css" scoped>
.back-btn {
  height: 80px;
  margin-top: 20px;
  margin-left: 710px;
}

.align-center {
  text-align: center
}

.exam-question-item {
  padding: 10px;
}

.el-form-item__label {
  font-size: 15px !important;
}


.question-title-padding {
  padding-left: 25px;
  padding-right: 25px;
}

.sec-title {
  margin-right: 50px;
  font-weight: normal;
}

.slogan {
  background-color: #eee;
  height: 40px;
}

.slogan p {
  width: 1200px;
  margin: 0 auto;
  color: #aaa;
  font-size: 13px;
  line-height: 40px;
}

</style>
